-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: createBaseRouter in TS #1022
Conversation
src/Redirect.tsx
Outdated
class RedirectType extends React.Component<RedirectOptions> { | ||
// @ts-ignore | ||
constructor(config: RedirectOptions); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know whether there's a better way to do this. The problem is i need consumer(the user of the library) to think this component extends React.Component
but I don't want to actually extend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is ok but maybe do:
declare class RedirectType extends React.Component<RedirectOptions> {
constructor(config: RedirectOptions);
}
with the declare which should make it just a type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, it works 😄
path?: string; | ||
|
||
to: string | ((match: Match) => LocationDescriptor); | ||
|
||
status?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to just declare fields on classes. Technically those are functional changes, but practically they should not change anything. I'm pretty sure the only difference is that this
has those initialized as undefined
when creating the instance, which should not change anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Nice work, I was dreading these weird objects :P |
This one was the most painful to do :P